package com.maven;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

/**
 * annotation 是实现方式来实现对应的功能
 *
 * @author L
 */
@Mojo(name = "annotation", defaultPhase = LifecyclePhase.PACKAGE)
public class AnnotationMojo extends AbstractMojo {


    /**
     * 这个注解用于支持 maven 表达式，${} 用于注入
     */
    @Parameter(defaultValue = "${default}")
    private MavenProject mavenProject;

    @Parameter(required = true)
    private String name;

    @Parameter(required = false)
    private String age;

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        final Log log = getLog();
        log.info("正在执行 annotation 的 maven plugin 方式");
        log.info("name 的值为：" + name);
        log.info("age 的值为：" + age);
        System.out.println("get params is " + mavenProject);
    }
}
